function openServiceoptionsPopup(){
	jQuery('#basic-modal-content-serviceoption').modal();
	jQuery('#serviceoption-edit').val(0);
}
function saveServiceoption(){
	var params = {}; 
	//jQuery("#add-serviceoption-form") .find("input[@checked], input[@type='text'], input[@type='hidden'], input[@type='password'], input[@type='submit'], option[@selected], textarea") .filter(":enabled") .each(function() {
	jQuery("#add-serviceoption-form") .find("input[checked], input[type='text'], input[type='hidden'], input[type='password'], input[type='submit'], option[selected], textarea").each(function() {
		params[ this.name || this.id || this.parentNode.name || this.parentNode.id ] = this.value; 
	});
	if(jQuery('#serviceoption-edit').val() == "0"){
		jQuery.post("./admin/database_definition/serviceoptions/ajax_serviceoption_save", params,
			function(data) {
				res = eval('(' + data + ')');
				if(res.result){
					jQuery('#escort-option').tabs( "load" , 8 );
					jQuery.modal.close();
					jQuery('#content-body').prepend('<div class="alert success">'+ res.message+'</div>');
				}else{
					jQuery('form#add-serviceoption-form section.item').prepend('<div class="alert error">'+ res.message+'</div>');
				}
			}
		);
	}else{
		jQuery.post("./admin/database_definition/serviceoptions/ajax_serviceoption_update", params,
			function(data) {
				res = eval('(' + data + ')');
				if(res.result){
					jQuery('#serviceoption_id').val("");
					jQuery("#serviceoption").val("");
					jQuery('#escort-option').tabs( "load" , 8 );
					jQuery.modal.close();
					jQuery('#content-body').prepend('<div class="alert success">'+ res.message+'</div>');
				}else{
					jQuery('form#add-serviceoption-form section.item').prepend('<div class="alert error">'+ res.message+'</div>');
				}
		 	}
		);
	}
}


function editServiceoption(code){
	jQuery.post("./admin/database_definition/serviceoptions/ajax_serviceoption_get", { code: code},
		function(data) {
//		alert(data);
			res = eval('(' + data + ')');
			for (i = 0; i < res.length; i++) {
				jQuery("#add-serviceoption-form input[name='serviceoption["+res[i].language_id+"]']").val(res[i].service);
				jQuery("#add-serviceoption-form input[name='serviceoption_id["+res[i].language_id+"]']").val(res[i].id);
				jQuery("#serviceoption-code").val(res[i].code);
			}
			jQuery('#basic-modal-content-serviceoption').modal();
			jQuery('#serviceoption-edit').val(1);
	 	}
	);
	return false;
}
function deleteServiceoption(code, message){
	confirm(message, function () {
		jQuery.post("./admin/database_definition/serviceoptions/ajax_serviceoption_delete", { code: code},
			function(data) {
				res = eval('(' + data + ')');
				if(res.result){
					jQuery('#escort-option').tabs( "load" , 8 );
					jQuery('#content-body').prepend('<div class="alert success">'+ res.message+'</div>');
				}else{
					jQuery('#content-body').prepend('<div class="alert error">'+ res.message+'</div>');
				}
		 	}
		);
		return false;
	});
	return false;
}